define(
		[ "PDUtilDir/grid", "PDUtilDir/searchBlock", "PDUtilDir/slidebar" ],
		function(Grid, SearchBlock, Slidebar) {

			function init(cache, detailObj, searchObj/*, payObj, updateObj, applyUpdateObj, payObject*/) {
				SearchBlock.init('searchBlockId');
				var supplerOrgType = '', strObj = {
					applyUpdate : '<a href="javascript:angular.element(\'#ServiceOrderGirdDivId\').scope().applyUpdate.run',
					applyUpdate_suffix : '">修单</a>',

					closeOrder : '<a href="javascript:angular.element(\'#ServiceOrderGirdDivId\').scope().closeOrder.run',
					closeOrder_suffix : '">关闭</a>',
//
//					cancelOrder : '<a href="javascript:angular.element(\'#ServiceOrderGirdDivId\').scope().cancelOrder.run',
//					cancelOrder_suffix : '">取消</a>',

					payOrder : '<a href="javascript:angular.element(\'#ServiceOrderGirdDivId\').scope().paySupport.run',
					payOrder_suffix : '">支付</a>',

//					applyRefund : '<a href="javascript:angular.element(\'#ServiceOrderGirdDivId\').scope().applyRefund.run',
//					applyRefund_suffix : '">退款</a>',

                    rebackRecode : '<a href="javascript:angular.element(\'#ServiceOrderGirdDivId\').scope().rebackRecode.run',
                    rebackRecode_suffix : '">退款记录</a>',

					doneOrder : '<a href="javascript:angular.element(\'#ServiceOrderGirdDivId\').scope().doneOrder.run',
					doneOrder_suffix : '">完成</a>',
					
					detailForPayOrder : '<a href="javascript:angular.element(\'#ServiceOrderGirdDivId\').scope().detailForPayOrder.run',
					detailForPayOrder_suffix : '">支付详情</a>',
					
					reply : '<a href="javascript:angular.element(\'#ServiceOrderGirdDivId\').scope().replyFun.run',
					reply_suffix : '">确认</a>'
				}, getStr = function(oper, id) {
					return strObj[oper] + '(\'' + id + '\')'
							+ strObj[oper + '_suffix'];
				};
                // console.info(cache.supplierOrgId);
				// 初始化
				return Grid({
					id : "ServiceOrderGirdDivId",
					pageSize : 10,
					index : true,
					multi : true,
					pagination : true,
					cache : false,
					layout : [
							{
								name : "订单号",
								field : "orderNo",
                                width: '210px',
								sort : false,
								click : function(e) {
									detailObj.run(e.data.row.id);
								}
							},
							{
								name : "团名称",
								field : "groupName",
                                width: '260px',
								sort : true
							},
							/*{
								name : "供应商",
								field : "splierName"
							},*/
							{
								name : "应付款",
								field : "shouldPayment"
							},
							{
								name : "支付状态",
								field : "payStatus",
								format : function(e) {
									return cache.orderStatusMap.get(e.row.payStatus);
								}
							},
							{
								name : "创建时间",
                                width: '160px',
								field : "createTime"
							},
							{
								name : "操作",
								field : "createTime",
								sort : false,
								width: '200px',
								format : function(e) {
									var data = e.row, id = data.id, orderNo = data.orderNo, status = data.payStatus, str = '';
									/*
									 * 所处状态1
									 *    待确认
									 * 操作
									 *    确认
									*/
									// console.info(cache.supplierOrgId);
                                    // console.info(data.supplerOrgId)
                                    // console.info(cache.supplierOrgId == data.supplerOrgId)
									if (status == "D_SERVICE_ORDER_STATUS_WAIT_CONDIFRM") {
										str += getStr('closeOrder', orderNo);
									}
									if(cache.supplierOrgId == data.supplerOrgId){
										if (status == "D_SERVICE_ORDER_STATUS_WAIT_CONDIFRM") {
											str += getStr('reply', orderNo);
										}

                                        if (status == "D_SERVICE_ORDER_STATUS_WAIT_PAY" || status == "D_SERVICE_ORDER_STATUS_PART_PAY") {
                                            str += getStr('applyUpdate', id);
                                        }
									}else{
										/*
										 * 所处状态2
										 *    待支付
										 * 操作
										 *    支付、修单
										*/
										if (status == "D_SERVICE_ORDER_STATUS_WAIT_PAY") {
											str += getStr('payOrder', id);
											str += getStr('applyUpdate', id);
										}
										/*
										 * 所处状态3
										 *    部分支付
										 * 操作
										 *    支付、修单
										*/
										if (status == "D_SERVICE_ORDER_STATUS_PART_PAY") {
											str += getStr('payOrder', id);
											str += getStr('applyUpdate', id);
										}
										/*
										 * 所处状态4
										 *    付款完成
										 * 操作
										 *    订单完成
										*/
										if (status == "D_SERVICE_ORDER_STATUS_PAYALL") {
											str += getStr('doneOrder', orderNo);
										}
										/*
										 * 所处状态5
										 *    订单关闭
										 * 操作
										 *    无
										*/
									}
									str += getStr('detailForPayOrder', orderNo);
                                    str += getStr('rebackRecode', orderNo);
									return str;
								}
							} ],
					toolbar : [ /*
								 * { name : "添加", icon : "fa fa-plus-circle",
								 * callback : function(event) { addObj.run(); } } {
								 * name : "支付", icon : "fa fa-trash-o", callback :
								 * function(event) { payObj.run(); } },
								 */{
						name : "查询",
						icon : "fa fa-search",
						callback : function(event) {
							searchObj.run();
						}
					} /*
						 * , { name : "立即支付", icon : "fa fa-search", callback :
						 * function(event) { payObject.run(); } }, { name :
						 * "申请修单", icon : "fa fa-search", callback :
						 * function(event) { applyUpdateObj.run(); } }, { name :
						 * "修改", icon : "fa fa-search", callback :
						 * function(event) { updateObj.run(); } }
						 */],
					data : {
						type : 'URL',
						value : getServer()
								+ '/flea/hclv/serviceOrder/findAllOrgOrder.htmls'
					}
				});
			}
			return {
				init : init
			}
		});